import React, { useState } from 'react'
import { Navigate } from 'react-router-dom'

export default function Home() {
  const [sum, setSum] = useState(1)

  return (
    <div>
      <h3>我是Home的内容</h3>
      {/* replace={true}：默认为false。浏览器追加还是替换的两种模式 */}
      {sum == 2 ? <Navigate to="/about" replace={true} /> : <h3>当前sum：{sum}</h3>}
      <div onClick={() => setSum(2)}>点击sum变成2</div>
    </div>
  )
}
